// Utility.h

#pragma once
#ifndef UTILITY_H_INCLUDED
#define UTILITY_H_INCLUDED

#include <string>
#include <fstream>

class SimpleRand
{
public:
	int m_iHold;

	SimpleRand();

	void Seed();
	void Seed(int p_iSeed);

	int Rand();	// 0-32767
};

class ThreadLock
{
	struct Dummy
	{
		char m_acData[48];
	} m_xDummy;
public:
	ThreadLock();
	~ThreadLock();

	void Lock();
	void Unlock();
};

class xString
{
public:
	static char** Split(const char token, char* input, int& p_count);
	void Replace(char old_token, char new_token, char* p_string);
	static std::string getExtension(std::string path);
};

class xFile
{
public:
	xFile();
	~xFile();

	enum
	{
		BINARY = 0,
		TEXT = 1
	};

	bool Open(const char* filePath, int mode);
	void Close();

	char* ReadFile();
	bool Exists(const char* filePath);
	unsigned int GetSize() {return m_uiFileSize;};

private:
	std::ifstream m_xStream;
	const char* m_cFilePath;
	int m_iMode;
	unsigned int m_uiFileSize;
};

class xCompress
{
public:
	xCompress();
	~xCompress();

	void Compress(char* p_cArray);
};

#endif // UTILITY_H_INCLUDED

